#!/bin/bash
#chkconfig:345 99 01
#description:applecd
export PKG_CONFIG_PATH='/usr/local/lib/pkgconfig'
export LD_LIBRARY_PATH='/usr/local/lib':$LD_LIBRARY_PATH
DIR='/root/applecd'
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NODE_PATH='$DIR/node_modules'
NODE=/usr/local/bin/node

test -x $NODE || exit 0
function start_app {
    forever start "$DIR/app.js" -l "$DIR/logs/applecd.log" -o "$DIR/logs/applecd.out.log" -e "$DIR/logs/applecd.err.log"
}
function stop_app {
    forever stop "$DIR/app.js"
}
case $1 in
    start)
        start_app ;;
    stop)
        stop_app ;;
    restart)
        stop_app
        start_app
        ;;
    *)
    echo "usage: clearstonecc {start|stop}" ;;
esac
exit 0
